# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libdvdread
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=6.1.3
pkgrel=1
pkgdesc="Provides a simple foundation for reading DVD video disks (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url="https://www.videolan.org/developers/libdvdnav.html"
license=('spdx:GPL-2.0-or-later')
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools" "${MINGW_PACKAGE_PREFIX}-cc")
depends=("${MINGW_PACKAGE_PREFIX}-libdvdcss")
options=('staticlibs' 'strip')
source=("https://download.videolan.org/pub/videolan/${_realname}/${pkgver}/${_realname}-${pkgver}.tar.bz2"{,.asc}
        0001-no-undefined-on.all.patch)
sha256sums=('ce35454997a208cbe50e91232f0e73fb1ac3471965813a13b8730a8f18a15369'
            'SKIP'
            'd8930c4167b9f9524b164f3ab918c3e8289acca3d86cd92146fd79453a5e9b58')
validpgpkeys=('65F7C6B4206BD057A7EB73787180713BE58D1ADC') # VideoLAN Release Signing Key

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/0001-no-undefined-on.all.patch
  autoreconf -fi
}

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --enable-static \
    --disable-dlfcn \
    --with-libdvdcss
  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make DESTDIR="${pkgdir}" install
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
